package ControllerLayer;
import ModelLayer.*;
import java.util.ArrayList;


/**
 * Write a description of class SalesController here.
 * 
 * @author (Morten Søndergaard) 
 * @version (28-05-2013)
 */
public class SalesController
{
    // instance variables - replace the example below with your own
    private OrderContainer orderContainer;
    private WarehouseController itemController;
    private PersonController personController;

    /**
     * Constructor for objects of class SalesController
     */
    public SalesController()
    {
        orderContainer = orderContainer.getInstance();
        personController = new PersonController();
        itemController = new WarehouseController();
    }

    /**
     * Method to creating an Order object and adding it to the OrderContainer
     * 
     * @param    
     * @return    object of the type Order and adding it to the ArrayList in the orderContainer 
     */
    public Order createOrder()
    {
        Order o = new Order();
        orderContainer.addOrder(o);
        return o;
    }
    
    public Customer createCustomer(Order o, String customerNo, String customerGroup, String firstName, String lastName, 
    		String company, String cvrNo, String address, String phone, String email)
    {
        Customer c = personController.createCustomer(customerNo, customerGroup, firstName, lastName, company, cvrNo, address, phone, email);
        o.addCustomer(c);
        return c;
    }
  
    public PartOrder addPartOrder(Order o, int ItemId, int quantity)
    {
        Item i = itemController.getItem(ItemId);
        return o.addPartOrder(i, quantity);
        
    }
    
    public void endOrder(Order o)
    {
        o.changeStatus(1);
        //nedskriv lager!!!!!!!!!! (Jan)
    }
 
}
